//
//  VideoCell.m
//  WMVideoPlayer
//
//  Created by zhengwenming on 16/1/17.
//  Copyright © 2016年 郑文明. All rights reserved.
//

#import "VideoCell.h"
#import "SNKVideoData.h"
#import "UIImageView+WebCache.h"

@implementation VideoCell

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

-(void)setVideo:(SNKVideoData *)video{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.titleLabel.text = video.title;
    self.descriptionLabel.text = video.descriptionDe;
    [self.backgroundIV sd_setImageWithURL:[NSURL URLWithString:video.cover] placeholderImage:[UIImage imageNamed:@"logo"]];
    self.countLabel.text = @"688";
    self.timeDurationLabel.text = [self convertTime:video.length];
}

//时间转换
- (NSString *)convertTime:(CGFloat)second{
    
    NSDateFormatter *fmt = [[NSDateFormatter alloc]init];
    NSDate *d = [NSDate dateWithTimeIntervalSince1970:second];
    if (second/3600 >= 1) {
        [fmt setDateFormat:@"HH:mm:ss"];
    } else {
        [fmt setDateFormat:@"mm:ss"];
    }
    NSString *showtimeNew = [fmt stringFromDate:d];
    return showtimeNew;
}

//各个cell间距值为10
- (void)setFrame:(CGRect)frame{
    frame.size.height -= 10;
    frame.origin.y += 10;
    //重写覆盖frame
    [super setFrame:frame];
}

@end
